package C;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class C1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        ArrayList<HashMap<String,Integer>> cnts = new ArrayList<>();
        for (int i = 0; i < n;i++){
            String url = sc.next();
            String[] urlComponents = url.split("/");

            for (int level = 0; level < urlComponents.length; level++){
                String urlComponent = urlComponents[level];
                if (cnts.size() <= level) {
                   cnts.add(new HashMap<>());
                }

                HashMap<String, Integer> map = cnts.get(level);
                map.put(urlComponent,map.getOrDefault(urlComponent,0)+1);
            }
        }

        int tar_level = sc.nextInt();
        String tar_urlComponent = sc.next();
        if (cnts.size() <= tar_level) {
            System.out.println(0);
        } else {
            System.out.println(cnts.get(tar_level).getOrDefault(tar_urlComponent,0));
        }


    }
}
